package com.xudu.xianrendongculturaltravelbackend.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.google.gson.Gson;
import com.xudu.xianrendongculturaltravelbackend.model.vo.ScenicVO;
import lombok.Data;
import org.springframework.beans.BeanUtils;

/**
 * 
 * @TableName scenic
 */
@TableName(value ="scenic")
@Data
public class Scenic implements Serializable {
    /**
     * 景点id
     */
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    /**
     * 景点名称
     */
    private String scenicName;

    /**
     * 封面图片
     */
    private String coverImage;

    /**
     * 景点介绍
     */
    private String scenicBrief;

    /**
     * 景点标签
     */
    private String tags;

    /**
     * 建议
     */
    private String tips;

    /**
     * 景点经度
     */
    private Double scenicLongitude;

    /**
     * 景点维度
     */
    private Double scenicLatitude;

    /**
     * 景点图片
     */
    private String scenicImages;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 是否删除
     */
    private Integer isDelete;

    public static ScenicVO objToVo(Scenic scenic){
        ScenicVO scenicVO = new ScenicVO();
        BeanUtils.copyProperties(scenic,scenicVO);
        Gson gson = new Gson();
        List<String> tags = gson.fromJson(scenic.getTags(), List.class);
        scenicVO.setTags(tags);
        List<String> scenicImages = gson.fromJson(scenic.getScenicImages(), List.class);
        scenicVO.setScenicImages(scenicImages);
        return scenicVO;
    }

    @Serial
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}